<?php
/**
 * 会员管理模型
 */
namespace app\model;

use laytp\BaseModel;
use think\model\concern\SoftDelete;

class Member extends BaseModel
{
	use SoftDelete;

    //模型名
    protected $name = 'member';

    //附加属性
    protected $append = ['vip_time_int','login_time_int','create_time_int','update_time_int','delete_time_int'];

    //时间戳字段转换
    protected $type = [
		'vip_time'  =>  'timestamp:Y-m-d H:i:s',
	];

    //表名
    

    //关联模型
    public function avatarPicFile(){
        return $this->belongsTo('app\model\Files','avatar_pic','id');
    }

    //新增属性的方法
    public function getVipTimeIntAttr($value, $data)
	{
		return isset($data['vip_time']) ? $data['vip_time'] : 0;
	}

	public function getLoginTimeIntAttr($value, $data)
	{
		return isset($data['login_time']) ? strtotime($data['login_time']) : 0;
	}

	public function getCreateTimeIntAttr($value, $data)
	{
		return isset($data['create_time']) ? strtotime($data['create_time']) : 0;
	}

	public function getUpdateTimeIntAttr($value, $data)
	{
		return isset($data['update_time']) ? strtotime($data['update_time']) : 0;
	}

	public function getDeleteTimeIntAttr($value, $data)
	{
		return isset($data['delete_time']) ? strtotime($data['delete_time']) : 0;
	}
}
